"""
@Author  : 康帅
@Time    : 2021/1/5 10:24
@Function: 了解如何在闭包里使用外围作用域中的变量
"""


def sort_priority(value, group):
    def helper(x):
        if x in group:
            return (0, x)
        return (1, x)

    value.sort(key=helper)


numbers = [8, 3, 1, 5, 7]
group = {2, 3, 5, 7}
sort_priority(numbers, group)
print(numbers)
